﻿<presentation:PhoneView
    x:Name="PageRoot"
    x:Class="OnYourWayHome.ApplicationModel.Presentation.Views.ShoppingListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:presentation="clr-namespace:OnYourWayHome.ApplicationModel.Presentation;assembly=OnYourWayHome.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" 
    Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    d:DataContext="{d:DesignData ShoppingListViewDesignData.xaml}" >

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <controls:Pivot Title="{StaticResource AppName}">
            <controls:PivotItem Header="shopping list">
                <ScrollViewer>

                    <ItemsControl ItemsSource="{Binding GroceryItems}">

                        <ItemsControl.ItemTemplate>

                            <DataTemplate>
                                <Grid Width="450" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="100"/>
                                    </Grid.ColumnDefinitions>

                                    <CheckBox 
                                        Grid.Column="0"
                                        Margin="0,-13, 0,-13"
                                        Content="{Binding Name}" 
                                        IsChecked="{Binding IsInCart}" 
                                        Command="{Binding DataContext.ChangeIsInCartCommand, ElementName=PageRoot}" 
                                        CommandParameter="{Binding}" />

                                    <Button Grid.Column="1"
                                        Padding="0,0,0,0"
                                        Width="45"
                                        Height="45"
                                        BorderThickness="0"
                                        Command="{Binding DataContext.RemoveItemCommand, ElementName=PageRoot}"
                                        CommandParameter="{Binding}">

                                        <Image Source="/Assets/appbar.delete.rest.png"/>

                                    </Button>
                                </Grid>

                            </DataTemplate>

                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <presentation:PhoneView.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Assets/appbar.add.rest.png" Text="add..." Click="AddClick"/>
            <shell:ApplicationBarIconButton IconUri="/Assets/appbar.money.png" Text="check out" Click="CheckoutClick"/>
        </shell:ApplicationBar>
    </presentation:PhoneView.ApplicationBar>

</presentation:PhoneView>